package Work4.Slay_the_Maze.Monsters;

import Work4.Slay_the_Maze.Monsters.InterFace.*;
import Work4.Slay_the_Maze.Player.*;
import java.util.Random;

public class Slime extends Monster implements Acid {
	public Slime() {
		super("史莱姆",20);
	}
	public Slime(Slime other) {
        // 调用父类的构造函数，复制父类属性
        super(other.getName(), other.getHP());
    }

    // 克隆方法
    @Override
    public Monster clone() {
        return new Slime(this);  // 使用拷贝构造函数
    }
    @Override
    public void Action(Player player,Monster monster) {
        int temp;
        Random rd=new Random();
       	temp=rd.nextInt(100)+1;
       	if(temp>=1&&temp<=50) {
       		int num=attack(player);
       		System.out.println("史莱姆使用撞击，造成"+num+"伤害");
       	}else if(temp>50&&temp<=70){
       		int num=0;
       		num+=attack(player);
       		num+=attack(player);
       		System.out.println("史莱姆使用连续撞击，造成"+num+"伤害");
       	}else if(temp>70&&temp<=90) {
       		acid(player);
       		System.out.println("史莱姆使用酸液，使你的护甲减半");
       	}else if(temp>90&&temp<=100) {
       		recovery();
       		System.out.println("史莱姆使用复原，获得10点血量");
       	}
      }
    
    public void recovery() {
    	setHp(getHp()+10);
    }
    
    @Override
    public int attack(Player target) {
        Random rd=new Random();
        int attnum=rd.nextInt(11)+5;
        target.damage(attnum);
        return attnum;
    }

    @Override
    public void acid(Player target) {
        target.setArmor(target.getArmor()/2);
    }
}
